
part of appcommon;

class NullWidget<T> extends StatelessWidget {
  const NullWidget(this.value, {required this.builder,
    this.placeHolder = const SizedBox(),
    this.predict});
  final T? value;
  final Widget Function(BuildContext, T) builder;
  final Widget placeHolder;
  final bool Function(T)? predict;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    if (value == null || (predict?.call(value as T) ?? false)) {
      return placeHolder;
    }else {
      return builder(context, value as T);
    }
  }
}